package com.sgcc.fj.pmos.common.utils;

import android.graphics.drawable.GradientDrawable;
import android.view.View;

public class GradientDrawableUtil {


    /**
     * 圆角矩形
     *
     * @param view
     * @param bgColor
     * @param radius
     */
    public static void filletRect(View view, int bgColor, int radius) {
        GradientDrawable gradientDrawable = new GradientDrawable();
        gradientDrawable.setShape(GradientDrawable.RECTANGLE);
        gradientDrawable.setColor(bgColor);
        gradientDrawable.setCornerRadius(radius);
        view.setBackground(gradientDrawable);


    }

    /**
     * 矩形
     *
     * @param view
     * @param bgColor
     */
    public static void rect(View view, int bgColor) {
        GradientDrawable gradientDrawable = new GradientDrawable();
        gradientDrawable.setShape(GradientDrawable.RECTANGLE);
        gradientDrawable.setColor(bgColor);
        view.setBackground(gradientDrawable);


    }

    /**
     * 圆形
     *
     * @param view
     * @param bgColor
     * @param radius
     */
    public static void filletOval(View view, int bgColor, int radius) {
        GradientDrawable gradientDrawable = new GradientDrawable();
        gradientDrawable.setShape(GradientDrawable.OVAL);
        gradientDrawable.setColor(bgColor);
        gradientDrawable.setCornerRadius(radius);
        view.setBackground(gradientDrawable);


    }

    /**
     * 圆角矩形带边框
     *
     * @param view
     * @param bgColor
     * @param strokeWidth 边框宽
     * @param strokeColor 边框颜色
     * @param radius      圆角值
     */
    public static void filletRectStroke(View view, int bgColor, int strokeWidth, int strokeColor, int radius) {
        GradientDrawable gradientDrawable = new GradientDrawable();
        gradientDrawable.setShape(GradientDrawable.RECTANGLE);
        gradientDrawable.setColor(bgColor);
        gradientDrawable.setStroke(strokeWidth, strokeColor);
        gradientDrawable.setCornerRadius(radius);
        view.setBackground(gradientDrawable);


    }
}
